<?php
/**
 * 任务完成日志
 * author itholiday@126.com
 */
global $_W, $_GPC;
load()->func('tpl');
$html_title = $_W['current_module']['title'];
$op = !empty($_GPC['op']) ? $_GPC['op'] : 'list';
////$op =$_GPC['op'];
////页面显示条数
$pagesize = 20;
$page = max(1, $_GPC['page']);
$start = ($page - 1) * $pagesize;

$where = "A.id>0";

$user_id = isset($_GPC['user_id']) && !empty($_GPC['user_id']) ? input('user_id') : '';
$mobile = isset($_GPC['mobile']) && !empty($_GPC['mobile']) ? input('mobile') : '';
$start_time = isset($_GPC['start_time']) && !empty($_GPC['start_time']) ? strtotime($_GPC['start_time']) : '';
$end_time = isset($_GPC['end_time']) && !empty($_GPC['end_time']) ? strtotime($_GPC['end_time']) : '';

if (!empty($mobile)){
    $where .= " and B.mobile like '%$mobile%' ";
}
if (!empty($user_id)){
    $where .= " and A.user_id like '%$user_id%' ";
}
if (!empty($start_time) && !empty($end_time)) {
    $where .= " and A.create_time>=$start_time and A.create_time<=$end_time ";
} else {
    if (!empty($start_time)) {
        $where .= " and A.create_time>=$start_time ";
    }
    if (!empty($end_time)) {
        $where .= " and A.create_time<=$end_time ";
    }
}

if ($op == "list" || $op == ""){
    $pagediv = 'list';
    $total = pdo_fetchcolumn('SELECT COUNT(*) AS `number` FROM ' . tablename('yq_haircircle_user_money_log') . 'A left join ims_yq_haircircle_users B on A.user_id=B.id WHERE ' . $where);

    //收支合计
    $sql1 = "select SUM(A.change) as money from ims_yq_haircircle_user_money_log A left join ims_yq_haircircle_users B on A.user_id = B.id where $where order by A.id limit $start,$pagesize";
    $coin = pdo_fetchall($sql1);
    //生成分页HTML
    $pager = getPageHTML($total, $page, $pagesize);
    $sql = "select A.*,B.alipay_name,B.truename,B.alipay_account from ims_yq_haircircle_user_money_log A left join ims_yq_haircircle_users B on A.user_id = B.id where $where order by A.id  desc limit $start,$pagesize";
    $list = pdo_fetchall($sql);
    include $this->template('web/user_money_log');
    exit;
}




